package test.config;


import com.config.CacheConfig;
import com.config.JdbcConfig;
import com.config.MyBatisConfig;
import com.config.RedisConfig;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.*;
import org.springframework.core.io.ClassPathResource;


@Configuration   //表示 这个类 里面的符合spring 注解规范的对象都要生成

@ComponentScans({@ComponentScan("test"),@ComponentScan("com.web.dao"),@ComponentScan("com.web.service")})
@Import({JdbcConfig.class, MyBatisConfig.class, RedisConfig.class,
        CacheConfig.class})
public class SpringConfig{
    @Bean("propertyConfigurer")  //propertie的配置器将指定的properies添加
    public PropertyPlaceholderConfigurer getPropertyPalce(){
        PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = 	new PropertyPlaceholderConfigurer();//生成配置类
        //生成资源数组
        ClassPathResource[]  classPathResources = {new ClassPathResource("c3p0Test.properties"),
                new ClassPathResource("redis.properties"),
                        new ClassPathResource("log4j.properties"),new ClassPathResource("log4jdbc.log4j2.properties")
        };
        //classpth就是部署出来的classes的根目录
        propertyPlaceholderConfigurer.setLocations(classPathResources);//将指定资源注册加载
        return propertyPlaceholderConfigurer;
    }

}
